/*
 * i2c.h
 *
 *  Created on: Mar 21, 2011
 *      Author: Vishal Verma
 */

#ifndef I2C_H_
#define I2C_H_

#define SDA P1_0
#define SCL P1_1
#define EEPROM_READ_ADDR  0XA1
#define EEPROM_WRITE_ADDR 0XA0
#define HIGH  1
#define LOW   0
#define ACK   LOW
#define NACK  HIGH
#define SUCCESS HIGH
#define ERROR LOW
#define SET    1
#define CLEAR  0
#define PAGESIZE 256

#define TEST_NUM 0x81

#define NOP __asm nop __endasm 		/* No operation */

void start(void);
void stop(void);
unsigned char clock(void);
unsigned char write(unsigned char byte);
unsigned char read(unsigned char status);
unsigned char byte_write(unsigned int addr, unsigned char val);
unsigned char page_write(unsigned int addr, const unsigned char *str);
unsigned char byte_read(unsigned int addr );
unsigned char current_read(void);
unsigned int seq_read(unsigned int size, __idata unsigned char *buf, unsigned int addr);
void clear_eeprom(void);
void eeprom_reset();
unsigned int addrInterpret(unsigned int ipAddr);

#endif /* I2C_H_ */
